home *** CD-ROM | disk | FTP | other *** search
- /*
- StrBdr.cpp -- Loose Data Binder v 1.7:
- container class "form."
-
- (C) Copyright 1992 John W. Small
- All rights reserved
-
- PSW / Power SoftWare
- P.O. Box 10072
- McLean, Virginia 22102 8072 USA
- (703) 759-3838
-
- See notes in fbinder.hpp!
- */
-
-
- #ifndef StrBdr_HPP
- #include "StrBdr.hpp"
- #endif
-
- #include <string.h>
-
-
- int StrBdr::initData(/* StrBdr-declared data
- member initializers */)
- {
- // initialize any StrBdr-declared data
- // members here
- return 1; // success
- }
-
- voiD StrBdr::Dassign(voiD D, const voiD S)
- {
- while (*(char *)D)
- if ((*((char *)D)++ = *((char *)S)++ )
- == '\0') break;
- return D;
- }
-
- voiD StrBdr::Dnew(const voiD D)
- {
- // invokes char's copy initializer constructor
- return (voiD) strdup((char *)D);
- }
-
- void StrBdr::Ddelete(voiD D)
- {
- // invokes char's destructor
- delete (char *) D;
- }
-
- void StrBdr::Dstore(ostream& os, voiD D)
- {
- int i = strlen((char *)D);
-
- os << i << BDRendm;
- if (i)
- os.write((char *)D,i);
- }
-
- voiD StrBdr::Dload(istream& is)
- {
- char * D;
- int i;
-
- is >> i >> BDRnextm;
- if ((D = new char[i+i]) != (char *)0) {
- if (i)
- is.read(D,i);
- D[i] = '\0';
- }
- return (voiD) D;
- }
-
- void StrBdr::store(ostream& os)
- {
- Binder::store(os);
- // os << StrBdr-declared data members << BDRendm;
- // if (!os)
- // berror("unable to store StrBdr "
- // "data on stream");
- }
-
-
- StrBdR StrBdr::load(istream& is, StrBdR thiS)
- {
- int newed;
-
- // is >> StrBdr-declared data member initializers
- // >> BDRnextm;
- // if (!is) {
- // sberror("unable to load StrBdr "
- // "data from stream");
- // return StrBdR0;
- // }
- if (thiS)
- newed = 0;
- else {
- if ((thiS = new StrBdr(initVFTsOnly))
- == StrBdR0) {
- sberror("unable to construct "
- "new StrBdr for "
- "loading");
- return StrBdR0;
- }
- newed = 1;
- }
- if (!Binder::load(is,(BindeR)thiS)) {
- if (newed)
- delete (voiD) thiS;
- return StrBdR0;
- }
- if (!thiS->initData(/* StrBdr-declared data
- member initializers */)) {
- sberror("nunable to initialize StrBdr "
- "from reloaded stream data");
- if (newed)
- delete (voiD) thiS;
- return StrBdR0;
- }
- return thiS;
- }
-